﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Extensions.cs" company="TechBits">
//   Copyright (c) TechBits. All rights reserved.
// </copyright>
// <summary>
//   Defines the Extensions type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace IntelliShortCut.Data
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    /// <summary>
    /// Provides usefulls extensions methods.
    /// </summary>
    public static class Extensions
    {
        /// <summary>
        /// Clones a generic list.
        /// </summary>
        /// <param name="listToClone">The list to clone.</param>
        /// <typeparam name="T">The reference type that implements IClonable interface.</typeparam>
        /// <returns>
        /// A cloned list of type T.
        /// </returns>
        public static IList<T> Clone<T>(this IList<T> listToClone) where T : ICloneable
        {
            var clonedList = listToClone.Select(item => (T)item.Clone()).ToList();
            return clonedList;
        }
    }
}
